home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Freeware / Gobby 0.4.7 / gobby-0.4.7.exe / {app} / share / gtksourceview-2.0 / language-specs / haskell.lang < prev    next >
Extensible Markup Language  |  2008-09-09  |  8KB  |  226 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.  
  4.  Authors: Duncan Coutts, Anders Carlsson
  5.  Copyright (C) 2004, 2007 Duncan Coutts <duncan@haskell.org>
  6.  Copyright (C) 2004 Anders Carlsson <andersca@gnome.org>
  7.  
  8.  This library is free software; you can redistribute it and/or
  9.  modify it under the terms of the GNU Library General Public
  10.  License as published by the Free Software Foundation; either
  11.  version 2 of the License, or (at your option) any later version.
  12.  
  13.  This library is distributed in the hope that it will be useful,
  14.  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  Library General Public License for more details.
  17.  
  18.  You should have received a copy of the GNU Library General Public
  19.  License along with this library; if not, write to the
  20.  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  21.  Boston, MA 02111-1307, USA.
  22.  
  23. -->
  24. <language id="haskell" _name="Haskell" version="2.0" _section="Sources">
  25.   <metadata>
  26.     <property name="mimetypes">text/x-haskell</property>
  27.     <property name="globs">*.hs</property>
  28.   </metadata>
  29.  
  30.   <styles>
  31.     <style id="preprocessor" _name="Preprocessor" map-to="def:preprocessor"/>
  32.     <style id="comment"      _name="Comment"      map-to="def:comment"/>
  33.     <style id="variable"     _name="Variable"                         />
  34.     <style id="symbol"       _name="Symbol"                           />
  35.     <style id="keyword"      _name="Keyword"      map-to="def:keyword"/>
  36.     <style id="type"         _name="Data Type"    map-to="def:type"/>
  37.     <style id="string"       _name="String"       map-to="def:string"/>
  38.     <style id="character"    _name="Character"    map-to="def:character"/>
  39.     <style id="char-escape"  _name="Escaped Character" map-to="def:special-char"/>
  40.     <style id="float"        _name="Float"        map-to="def:floating-point"/>
  41.     <style id="decimal"      _name="Decimal"      map-to="def:decimal"/>
  42.     <style id="octal"        _name="Octal"        map-to="def:base-n-integer"/>
  43.     <style id="hexadecimal"  _name="Hex"          map-to="def:base-n-integer"/>
  44.   </styles>
  45.  
  46.   <definitions>
  47.     <!-- Spec: http://haskell.org/onlinereport/lexemes.html -->
  48.  
  49.     <define-regex id="symbolchar">[!#$%&*+./>=<?@:\\^|~-]</define-regex>
  50.  
  51.     <context id="line-comment" style-ref="comment" end-at-line-end="true">
  52.       <start>(?<!\%{symbolchar})--+(?!\%{symbolchar})</start>
  53.       <include>
  54.         <context ref="def:in-comment"/>
  55.         <context ref="haddock:line-paragraph"/>
  56.         <context ref="haddock:directive"/>
  57.       </include>
  58.     </context>
  59.  
  60.     <context id="block-comment" style-ref="comment">
  61.       <start>\{-</start>
  62.       <end>-\}</end>
  63.       <include>
  64.         <context ref="def:in-comment"/>
  65.         <context ref="haddock:block-paragraph"/>
  66.         <context ref="haddock:directive"/>
  67.         <context ref="block-comment"/>
  68.       </include>
  69.     </context>
  70.  
  71.     <context id="pragma" style-ref="preprocessor">
  72.       <start>\{-#</start>
  73.       <end>#-\}</end>
  74.     </context>
  75.  
  76.     <context id="variable" style-ref="variable">
  77.       <match>\b[a-z_][0-9a-zA-Z_'#]*</match>
  78.     </context>
  79.  
  80.     <context id="type-or-constructor" style-ref="type">
  81.       <match>\b[A-Z][0-9a-zA-Z._'#]*</match>
  82.     </context>
  83.  
  84.     <!-- Must not extend parent context, or we end up matching
  85.          "\end{code}" as part of the Haskell context, but when in
  86.          literate haskell mode it should be terminating a code block. -->
  87.     <context id="symbol" style-ref="symbol" extend-parent="false">
  88.       <match>\%{symbolchar}+</match>
  89.     </context>
  90.  
  91.     <context id="keysymbol" style-ref="keyword">
  92.       <prefix>(?<!\%{symbolchar})</prefix>
  93.       <suffix>(?!\%{symbolchar})</suffix>
  94.       <keyword>\.\.</keyword>
  95.       <keyword>::</keyword>
  96.       <keyword>=</keyword>
  97.       <keyword>\|</keyword>
  98.       <keyword>\</keyword>
  99.       <keyword>-></keyword>
  100.       <keyword><-</keyword>
  101.       <keyword>@</keyword>
  102.       <keyword>~</keyword>
  103.       <keyword>=></keyword>
  104.     </context>
  105.  
  106.     <define-regex id="escaped-character" extended="true">
  107.         \\(                   # leading backslash
  108.         [abfnrtv\\"\'&] | # escaped character
  109.          [0-9]+ |             # decimal digits
  110.         o[0-7]+ |             # 'o' followed by octal digits
  111.         x[0-9A-Fa-f]+ |       # 'x' followed by hex digits
  112.         \^[A-Z@\[\\\]^_] |    # control character codes
  113.         NUL | SOH | STX | ETX | EOT | ENQ | ACK |
  114.         BEL | BS | HT | LF | VT | FF | CR | SO |
  115.         SI | DLE | DC1 | DC2 | DC3 | DC4 | NAK |
  116.         SYN | ETB | CAN | EM | SUB | ESC | FS | GS |
  117.         RS | US | SP | DEL    # control char names
  118.         )
  119.     </define-regex>
  120.  
  121.     <context id="string" style-ref="string" end-at-line-end="true">
  122.       <start>"</start>
  123.       <end>"</end>
  124.       <include>
  125.         <context ref="def:line-continue"/>
  126.         <context style-ref="char-escape">
  127.           <match>\%{escaped-character}</match>
  128.         </context>
  129.       </include>
  130.     </context>
  131.  
  132.     <context id="char" style-ref="character" end-at-line-end="true">
  133.       <start>'</start>
  134.       <end>'</end>
  135.       <include>
  136.         <context style-ref="char-escape" once-only="true">
  137.           <match>\%{escaped-character}</match>
  138.         </context>
  139.         <context once-only="true" extend-parent="false">
  140.           <match>.</match>
  141.         </context>
  142.         <context style-ref="def:error" extend-parent="false">
  143.           <match>.</match>
  144.         </context>
  145.       </include>
  146.     </context>
  147.  
  148.     <context id="float" style-ref="float">
  149.       <match extended="true">
  150.           [0-9]+ \. [0-9]+ ([eE][+-]?[0-9]+)?
  151.         | [0-9]+            [eE][+-]?[0-9]+
  152.       </match>
  153.     </context>
  154.  
  155.     <context id="hexadecimal" style-ref="hexadecimal">
  156.       <match>0[xX][0-9a-fA-F]+</match>
  157.     </context>
  158.  
  159.     <context id="octal" style-ref="octal">
  160.       <match>0[oO][0-7]+</match>
  161.     </context>
  162.  
  163.     <context id="decimal" style-ref="decimal">
  164.       <match>[0-9]+</match>
  165.     </context>
  166.  
  167.     <context id="keyword" style-ref="keyword">
  168.       <keyword>case</keyword>
  169.       <keyword>class</keyword>
  170.       <keyword>data</keyword>
  171.       <keyword>default</keyword>
  172.       <keyword>deriving</keyword>
  173.       <keyword>do</keyword>
  174.       <keyword>mdo</keyword>
  175.       <keyword>else</keyword>
  176.       <keyword>forall</keyword>
  177.       <keyword>foreign</keyword>
  178.       <keyword>hiding</keyword>
  179.       <keyword>if</keyword>
  180.       <keyword>import</keyword>
  181.       <keyword>in</keyword>
  182.       <keyword>infix</keyword>
  183.       <keyword>infixl</keyword>
  184.       <keyword>infixr</keyword>
  185.       <keyword>instance</keyword>
  186.       <keyword>let</keyword>
  187.       <keyword>module</keyword>
  188.       <keyword>newtype</keyword>
  189.       <keyword>of</keyword>
  190.       <keyword>qualified</keyword>
  191.       <keyword>then</keyword>
  192.       <keyword>where</keyword>
  193.     </context>
  194.  
  195.     <context id="body">
  196.       <include>
  197.         <context ref="line-comment"/>
  198.         <context ref="pragma"/>
  199.         <context ref="block-comment"/>
  200.         <context ref="keyword"/>
  201.         <context ref="variable"/>
  202.         <context ref="type-or-constructor"/>
  203.         <context ref="keysymbol"/>
  204.         <context ref="symbol"/>
  205.         <context ref="string"/>
  206.         <context ref="char"/>
  207.         <context ref="float"/>
  208.         <context ref="hexadecimal"/>
  209.         <context ref="octal"/>
  210.         <context ref="decimal"/>
  211.       </include>
  212.     </context>
  213.  
  214.     <context id="haskell">
  215.       <include>
  216.         <context ref="def:shebang"/>
  217.         <context ref="c:if0-comment"/>
  218.         <context ref="c:include"/>
  219.         <context ref="c:preprocessor"/>
  220.         <context ref="body"/>
  221.       </include>
  222.     </context>
  223.  
  224.   </definitions>
  225. </language>
  226.